<script lang="ts" setup>
import { ref } from 'vue'
import user  from '../../api/user'
import { useUpdateUserPasswordStore } from '../../store/user/updateUserPassword';
import utils from '../../utils/utils';
const updateUserPasswordStore = useUpdateUserPasswordStore()
async function submit() {
    user.updateUserPassword(updateUserPasswordStore.newPassword, updateUserPasswordStore.id).then(res => {
        utils.showMessage(res.data.message, 'success', 1000)
        updateUserPasswordStore.setOpen(false)
        updateUserPasswordStore.newPassword = ''
        updateUserPasswordStore.id = 0
    }).catch(err => {
        console.log(err)
    })
}
const failed = () => {
    updateUserPasswordStore.setOpen(false)
}
</script>
<template>
    <el-dialog v-model="updateUserPasswordStore.isOpen" title="重置密码" width="500" align-center>
    <el-input type="password" v-model="updateUserPasswordStore.newPassword" placeholder="请输入新密码" show-password clearable/>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="submit">提交</el-button>
                <el-button type="primary" @click="failed">
                    取消
                </el-button>
            </div>
        </template>
    </el-dialog>
</template>